#第一题:输出1到100之间数之和

def firstText():
    a = 0
    b = 0
    while a <= 100:
        b += a
        a += 1
    print ("1~100之间的和为：", b)


#第二题：用户输入一个年份判断是否为闰年（能被4或400整除，不能被100整除）

def secondText():
    a = input("请输入一个年份")
    a = int(a)
    if a % 4 == 0 or a % 400 == 0 and a % 100 != 0:
        print ("闰年")
    else:
        print ("再见")


#第三题：判断2000到2500年中有多少个闰年

def thirdText():
    a = 2000
    b = 0
    while a <= 2500:
        if a % 4 == 0 and a % 100 != 0 or a % 400 == 0:
            a += 1
            b += 1
        else :
            a += 1
    print ("2000年-2500之间有", b, "个闰年")


#第四题：交换两个变量值

def fourthText():
    a1 = "o"
    b1 = "k"
    print (a1 + b1)

    c1 = a1
    a1 = b1
    b1 = c1
    print (a1 + b1)

    a2 = "k"
    b2 = "o"
    a2, b2 = b2, a2
    print (a2 + b2)

    a3 = 8
    b3 = 2
    a3 ^= b3
    b3 ^= a3
    a3 ^= b3
    print (a3, b3)


#第五题：计算输入一个数二进制中有多少个1(32位)

def fifthText():
    num = int(input("请输入一个牛逼的数字"))
    a = 0
    b = 0
    while a < 32:
        if num & (1 << a):
            b += 1
        a += 1
    print (num, "的二进制数中有", b, "个 1")


#第六题：输入一个数字，对此数字二进制位第3，5，7位置 1，
#           将2，6位置 0 再输出（不考虑负数）

def sixthText():
    num = int(input("请输入一个牛掰的数"))
    num |= (1 << 2 | 1 << 4 | 1 << 6)
    num &= ~ (1 << 1 | 1 << 5)
    print ("输出为：", num)


#第七题：一个袋子里有3个红球，3个绿球，6个黄球，一次从袋子里取6个球，
#           列出所有可能组合

def seventhText():
    for rBall in range(4):
        for gBall in range(4):
            yBall = 6 - rBall - gBall
            print (rBall, "个红球,", gBall, "个绿球,", yBall, "个黄球")


#第八题：公鸡5元一只，母鸡3元一只，小鸡1元3只，现在100元要买100只，
#           列出所有可能组合

def eighthText():
    for cock in range(21):
        for hen in range(34):
            chicken = 100 - cock - hen
            if chicken % 3 == 0 and cock * 5 + hen * 3 + chicken // 3 == 100:
                print (cock, "只公鸡", hen, "只母鸡", chicken, "只小鸡")

print ("欢迎来到英雄联盟，敌军还有30秒来到战场，请挑选您的装备，碾碎他们！")
print ("1:求和1~100")
print ("2:判断是否闰年")
print ("3:2000-2500间闰年")
print ("4:交换变量")
print ("5:二进制数里有多少个一")
print ("6:二进制位第3，5，7位置 1, 将2，6位置 0")
print ("7:红3绿3黄6，取6列组合")
print ("8:小明取菜市场买鸡")
print ("9:人工服务")
print ("0:退出游戏")
while True:
    num = int(input("请输入您要选择的装备："))
    if num == 1:
        firstText()
    elif num == 2:
        secondText()
    elif num == 3:
        thirdText()
    elif num == 4:
        fourthText()
    elif num == 5:
        fifthText()
    elif num == 6:
        sixthText()
    elif num == 7:
        seventhText()
    elif num == 8:
        eighthText()
    elif num == 9:
        print ("系统繁忙！")
    elif num == 0:
        break
    else:
        print ("输入有误，请重新输入！")


